package net.zjitc.servlet;

import javax.servlet.*;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Created by Administrator on 2017/9/25.
 */
public class GServlet extends GenericServlet{
    @Override
    public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
        //如何获得servletConfig
        ServletConfig config=this.getServletConfig();
        String value = config.getInitParameter("gKey");
        PrintWriter out = servletResponse.getWriter();
        out.write("gServlet value = ");
        out.write(value);



        ServletContext context=this.getServletContext();
        String path=context.getRealPath("/");//  斜杠表示真实路径
        out.write(path);
        out.write("这是测试页面");
    }
}
